<?php 
	set_include_path (PHPPATH);
	require_once 'MDB2.php';

	/**
	 * 
	 * The homepage controller
	 * @author Tri
	 *
	 */
	class home extends Application 
	{
		/**
		 * 
		 * Constructor
		 */
		function __construct(&$tmpl)
		{			
			$this->tmpl = &$tmpl;		
		}

		/**
		 * 
		 * Default action
		 */
		function index()
		{
			// about button visible and login visible
			$userId = $this->getLoggedUser();
			if($userId == 0) {
				$this->assign("loginLeftVisible", 1);
				$this->assign("aboutVisible", 0);
				//$this->assign("logoutVisible", 0);
			} else {
				$this->assign("loginLeftVisible", 0);
				$this->assign("aboutVisible", 1);
				//$this->assign("logoutVisible", 1);
			}
			// search button visible
			$this->assign("searchVisible", 1);
			
			
			//processing		
			$typeModel = $this->getModel('TypeModel');
			$types = $typeModel->getAllTypes();
			$typePath = $this->loadResources('type');
			//output
			$this->assign("types", $types);
			$this->assign("typesCount", count($types));
			$this->assign("imagesPath", $this->loadResources('images'));
			$this->assign("typePath", $typePath);
			$this->assign("title", "StylePad");
			$this->assign("currentView", "home");
			$this->loadTemplate('homepage');
		}
	}
?>